package com.ant.collect.common;

import com.ant.collect.handler.AntException;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @program: erp
 * @description: 接受分页工具类（含对象）
 * @author: FS
 * @create: 2021-12-02 16:46
 */
@Data
@ApiModel("后端接受的分页对象")
public class PageRecv<T>{
    //当前页码
    @ApiModelProperty(value = "当前页")
    private Integer currentPage=Constants.PAGE;
    //每页行数
    @ApiModelProperty(value = "每页行数")
    private Integer pageSize=Constants.LIMIT;
    //接受数据
    @ApiModelProperty(value = "数据")
    private T data;

    public void setCurrentPage(Integer currentPage) {
        if(currentPage <= 0){
            throw new AntException(ResultCode.PARAM_IS_INVALID);

        }else{
            this.currentPage = currentPage;
        }
    }

    public void setPageSize(Integer pageSize) {
        if (pageSize <= 0) {
            throw new AntException(ResultCode.PARAM_IS_INVALID);
        } else {
            this.pageSize = pageSize;
        }
    }
}